##STEP UP: LIBRARIES / POSTGRES CONNECTION

##GRAPH: cANDIDATE DIVERSITY

##         county_name geo_id nh_white_candidates nh_black_candidates
## 1    Trinity County  06105                   5                   0
## 2     Alpine County  06003                   4                   0
## 3  Del Norte County  06015                   5                   0
## 4  El Dorado County  06017                   6                   0
## 5 Santa Cruz County  06087                   4                   0
## 6   Humboldt County  06023                   5                   0
##   latino_candidates nh_api_candidates nh_aian_candidates
## 1                 0                 0                  0
## 2                 0                 0                  0
## 3                 0                 0                  0
## 4                 0                 0                  0
## 5                 0                 0                  0
## 6                 0                 0                  0
##   nh_twoormor_candidates total_candidates total_pop latino_pop
## 1                      0                6     13037        937
## 2                      0                4      1203        117
## 3                      0                6     27442       5281
## 4                      0                6    185015      23279
## 5                      0                4    273263      91096
## 6                      0                6    135490      14986
##   nh_white_pop nh_black_pop nh_aian_pop nh_api_pop nh_twoormor_pop
## 1        11284          104         559        279             395
## 2          826           18         263         16              80
## 3        21073          493        2158        797            2012
## 4       161881         1789        1347       8197            6775
## 5       211116         2424        1507      12808           12622
## 6       109346         1609        7042       4344            7831
##   total_raw nh_white_raw nh_black_raw latino_raw nh_api_raw nh_aian_raw
## 1         6            5            0          0          0           0
## 2         4            4            0          0          0           0
## 3         6            5            0          0          0           0
## 4         6            6            0          0          0           0
## 5         4            4            0          0          0           0
## 6         6            5            0          0          0           0
##   nh_twoormor_raw total_rate nh_white_rate nh_black_rate latino_rate
## 1               0  46.022858     44.310528             0           0
## 2               0 332.502078    484.261501             0           0
## 3               0  21.864296     23.727044             0           0
## 4               0   3.242980      3.706426             0           0
## 5               0   1.463791      1.894693             0           0
## 6               0   4.428371      4.572641             0           0
##   nh_api_rate nh_aian_rate nh_twoormor_rate        max nh_white_diff
## 1           0            0                0  44.310528             0
## 2           0            0                0 484.261501             0
## 3           0            0                0  23.727044             0
## 4           0            0                0   3.706426             0
## 5           0            0                0   1.894693             0
## 6           0            0                0   4.572641             0
##   nh_black_diff latino_diff nh_api_diff nh_aian_diff nh_twoormor_diff
## 1     44.310528   44.310528   44.310528    44.310528        44.310528
## 2    484.261501  484.261501  484.261501   484.261501       484.261501
## 3     23.727044   23.727044   23.727044    23.727044        23.727044
## 4      3.706426    3.706426    3.706426     3.706426         3.706426
## 5      1.894693    1.894693    1.894693     1.894693         1.894693
## 6      4.572641    4.572641    4.572641     4.572641         4.572641
##    mean_diff     variance index_of_disparity performance_z disparity_z
## 1  36.925440 2.726976e+02                100     0.7045291   0.8862749
## 2 403.551251 3.257072e+04                100     7.0850133   0.8862749
## 3  19.772537 7.819064e+01                100     0.1664680   0.8862749
## 4   3.088689 1.907999e+00                100    -0.2482672   0.8862749
## 5   1.578911 4.985919e-01                100    -0.2878934   0.8862749
## 6   3.810534 2.904034e+00                100    -0.2218661   0.8862749
##   nh_white_performance_z nh_black_performance_z latino_performance_z
## 1              0.4415780             -0.2289234            -0.316778
## 2              7.2638493             -0.2289234            -0.316778
## 3              0.1223921             -0.2289234            -0.316778
## 4             -0.1880654             -0.2289234            -0.316778
## 5             -0.2161597             -0.2289234            -0.316778
## 6             -0.1746331             -0.2289234            -0.316778
##   nh_api_performance_z nh_aian_performance_z nh_twoormor_performance_z
## 1           -0.2422268             -0.254805                         0
## 2           -0.2422268             -0.254805                         0
## 3           -0.2422268             -0.254805                         0
## 4           -0.2422268             -0.254805                         0
## 5           -0.2422268             -0.254805                         0
## 6           -0.2422268             -0.254805                         0
##   nh_white_disparity_z nh_black_disparity_z latino_disparity_z
## 1            -2.236068            0.4472136          0.4472136
## 2            -2.236068            0.4472136          0.4472136
## 3            -2.236068            0.4472136          0.4472136
## 4            -2.236068            0.4472136          0.4472136
## 5            -2.236068            0.4472136          0.4472136
## 6            -2.236068            0.4472136          0.4472136
##   nh_api_disparity_z nh_aian_disparity_z nh_twoormor_disparity_z
## 1          0.4472136           0.4472136               0.4472136
## 2          0.4472136           0.4472136               0.4472136
## 3          0.4472136           0.4472136               0.4472136
## 4          0.4472136           0.4472136               0.4472136
## 5          0.4472136           0.4472136               0.4472136
## 6          0.4472136           0.4472136               0.4472136
##   performance_rank disparity_rank quadrant
## 1                2              1   orange
## 2                1              1   orange
## 3                8              1   orange
## 4               27              1      red
## 5               37              1      red
## 6               22              1      red

##GRAPHNG LATINO UNINSURED PCT

##INTERACTIVE GRAPHS USING PLOTLY

##INTERACTIVE MAP

##   gid statefp countyfp countyns       affgeoid geoid         name lsad
## 1  19      06      001 01675839 0500000US06001 06001      Alameda   06
## 2  20      06      005 01675841 0500000US06005 06005       Amador   06
## 3  21      06      013 01675903 0500000US06013 06013 Contra Costa   06
## 4  22      06      023 01681908 0500000US06023 06023     Humboldt   06
## 5  23      06      037 00277283 0500000US06037 06037  Los Angeles   06
## 6  24      06      047 00277288 0500000US06047 06047       Merced   06
##         aland     awater
## 1  1909616630  216916717
## 2  1539933576   29470568
## 3  1857310903  225193562
## 4  9241251740 1254039383
## 5 10510588451 1794793532
## 6  5012175320  112509475
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
##   gid statefp countyfp countyns       affgeoid geoid         name lsad
## 1  19      06      001 01675839 0500000US06001 06001      Alameda   06
## 2  20      06      005 01675841 0500000US06005 06005       Amador   06
## 3  21      06      013 01675903 0500000US06013 06013 Contra Costa   06
## 4  22      06      023 01681908 0500000US06023 06023     Humboldt   06
## 5  23      06      037 00277283 0500000US06037 06037  Los Angeles   06
## 6  24      06      047 00277288 0500000US06047 06047       Merced   06
##         aland     awater
## 1  1909616630  216916717
## 2  1539933576   29470568
## 3  1857310903  225193562
## 4  9241251740 1254039383
## 5 10510588451 1794793532
## 6  5012175320  112509475
## class       : SpatialPolygonsDataFrame 
## features    : 6 
## extent      : -124.4096, -117.6464, 32.80146, 41.46584  (xmin, xmax, ymin, ymax)
## crs         : +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs 
## variables   : 10
## names       : gid, statefp, countyfp, countyns,       affgeoid, geoid,    name, lsad,       aland,     awater 
## min values  :  19,      06,      001, 00277283, 0500000US06001, 06001, Alameda,   06,  1539933576,   29470568 
## max values  :  24,      06,      047, 01681908, 0500000US06047, 06047,  Merced,   06, 10510588451, 1794793532

##INTERACTIVE MAP: BUT WITH QUANTILES INSTEAD OF BINS